<!-- HTML header for doxygen 1.8.13-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.14"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Taskflow Handbook</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link rel="icon" type="image/x-icon" href="favicon.ico" />
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  $(document).ready(initResizable);
/* @license-end */</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname"><a href="https://taskflow.github.io/">Taskflow</a>
   &#160;<span id="projectnumber">3.0.0-Master-Branch</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.14 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('cuda__memory_8hpp.html','');});
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">cuda_memory.hpp File Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p><a href="cuda__memory_8hpp_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a1effcf929b7e488925f9e12d74c8c62b"><td class="memItemLeft" align="right" valign="top"><a id="a1effcf929b7e488925f9e12d74c8c62b"></a>
size_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="cuda__memory_8hpp.html#a1effcf929b7e488925f9e12d74c8c62b">tf::cuda_get_free_mem</a> (int d)</td></tr>
<tr class="memdesc:a1effcf929b7e488925f9e12d74c8c62b"><td class="mdescLeft">&#160;</td><td class="mdescRight">queries the free memory (expensive call) <br /></td></tr>
<tr class="separator:a1effcf929b7e488925f9e12d74c8c62b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a58bbc8d5d955582d6b5f7fdac51d010b"><td class="memItemLeft" align="right" valign="top"><a id="a58bbc8d5d955582d6b5f7fdac51d010b"></a>
size_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="cuda__memory_8hpp.html#a58bbc8d5d955582d6b5f7fdac51d010b">tf::cuda_get_total_mem</a> (int d)</td></tr>
<tr class="memdesc:a58bbc8d5d955582d6b5f7fdac51d010b"><td class="mdescLeft">&#160;</td><td class="mdescRight">queries the total available memory (expensive call) <br /></td></tr>
<tr class="separator:a58bbc8d5d955582d6b5f7fdac51d010b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6f04fd3168c45eeb2dffb223e5c81e45"><td class="memTemplParams" colspan="2">template&lt;typename T &gt; </td></tr>
<tr class="memitem:a6f04fd3168c45eeb2dffb223e5c81e45"><td class="memTemplItemLeft" align="right" valign="top">T *&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="cuda__memory_8hpp.html#a6f04fd3168c45eeb2dffb223e5c81e45">tf::cuda_malloc_device</a> (size_t N, int d)</td></tr>
<tr class="memdesc:a6f04fd3168c45eeb2dffb223e5c81e45"><td class="mdescLeft">&#160;</td><td class="mdescRight">allocates memory on the given device for holding <code>N</code> elements of type <code>T</code>  <a href="cuda__memory_8hpp.html#a6f04fd3168c45eeb2dffb223e5c81e45">More...</a><br /></td></tr>
<tr class="separator:a6f04fd3168c45eeb2dffb223e5c81e45"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab9b68b8f4336f13b190d573969cb1cf7"><td class="memTemplParams" colspan="2">template&lt;typename T &gt; </td></tr>
<tr class="memitem:ab9b68b8f4336f13b190d573969cb1cf7"><td class="memTemplItemLeft" align="right" valign="top">T *&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="cuda__memory_8hpp.html#ab9b68b8f4336f13b190d573969cb1cf7">tf::cuda_malloc_device</a> (size_t N)</td></tr>
<tr class="memdesc:ab9b68b8f4336f13b190d573969cb1cf7"><td class="mdescLeft">&#160;</td><td class="mdescRight">allocates memory on the current device associated with the caller  <a href="cuda__memory_8hpp.html#ab9b68b8f4336f13b190d573969cb1cf7">More...</a><br /></td></tr>
<tr class="separator:ab9b68b8f4336f13b190d573969cb1cf7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8eed05685b030fc44703213a4ef86f11"><td class="memTemplParams" colspan="2">template&lt;typename T &gt; </td></tr>
<tr class="memitem:a8eed05685b030fc44703213a4ef86f11"><td class="memTemplItemLeft" align="right" valign="top">T *&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="cuda__memory_8hpp.html#a8eed05685b030fc44703213a4ef86f11">tf::cuda_malloc_shared</a> (size_t N)</td></tr>
<tr class="memdesc:a8eed05685b030fc44703213a4ef86f11"><td class="mdescLeft">&#160;</td><td class="mdescRight">allocates shared memory for holding <code>N</code> elements of type <code>T</code>  <a href="cuda__memory_8hpp.html#a8eed05685b030fc44703213a4ef86f11">More...</a><br /></td></tr>
<tr class="separator:a8eed05685b030fc44703213a4ef86f11"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac7a8fe7456b888d6072ba94783c5003c"><td class="memTemplParams" colspan="2">template&lt;typename T &gt; </td></tr>
<tr class="memitem:ac7a8fe7456b888d6072ba94783c5003c"><td class="memTemplItemLeft" align="right" valign="top">void&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="cuda__memory_8hpp.html#ac7a8fe7456b888d6072ba94783c5003c">tf::cuda_free</a> (T *ptr, int d)</td></tr>
<tr class="memdesc:ac7a8fe7456b888d6072ba94783c5003c"><td class="mdescLeft">&#160;</td><td class="mdescRight">frees memory on the GPU device  <a href="cuda__memory_8hpp.html#ac7a8fe7456b888d6072ba94783c5003c">More...</a><br /></td></tr>
<tr class="separator:ac7a8fe7456b888d6072ba94783c5003c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae174a3a49b91ef21554dac16806f0d72"><td class="memTemplParams" colspan="2">template&lt;typename T &gt; </td></tr>
<tr class="memitem:ae174a3a49b91ef21554dac16806f0d72"><td class="memTemplItemLeft" align="right" valign="top">void&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="cuda__memory_8hpp.html#ae174a3a49b91ef21554dac16806f0d72">tf::cuda_free</a> (T *ptr)</td></tr>
<tr class="memdesc:ae174a3a49b91ef21554dac16806f0d72"><td class="mdescLeft">&#160;</td><td class="mdescRight">frees memory on the GPU device  <a href="cuda__memory_8hpp.html#ae174a3a49b91ef21554dac16806f0d72">More...</a><br /></td></tr>
<tr class="separator:ae174a3a49b91ef21554dac16806f0d72"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa4266474b921f8ed7d9ec8071fded2a4"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="cuda__memory_8hpp.html#aa4266474b921f8ed7d9ec8071fded2a4">tf::cuda_memcpy_async</a> (cudaStream_t stream, void *dst, const void *src, size_t count)</td></tr>
<tr class="memdesc:aa4266474b921f8ed7d9ec8071fded2a4"><td class="mdescLeft">&#160;</td><td class="mdescRight">copies data between host and device asynchronously through a stream  <a href="cuda__memory_8hpp.html#aa4266474b921f8ed7d9ec8071fded2a4">More...</a><br /></td></tr>
<tr class="separator:aa4266474b921f8ed7d9ec8071fded2a4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6615554d2954e895755411ee444d9760"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="cuda__memory_8hpp.html#a6615554d2954e895755411ee444d9760">tf::cuda_memset_async</a> (cudaStream_t stream, void *devPtr, int value, size_t count)</td></tr>
<tr class="memdesc:a6615554d2954e895755411ee444d9760"><td class="mdescLeft">&#160;</td><td class="mdescRight">initializes or sets GPU memory to the given value byte by byte  <a href="cuda__memory_8hpp.html#a6615554d2954e895755411ee444d9760">More...</a><br /></td></tr>
<tr class="separator:a6615554d2954e895755411ee444d9760"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Function Documentation</h2>
<a id="file_ac7a8fe7456b888d6072ba94783c5003c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#file_ac7a8fe7456b888d6072ba94783c5003c">&#9670;&nbsp;</a></span>cuda_free() <span class="overload">[1/2]</span></h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T &gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">void tf::cuda_free </td>
          <td>(</td>
          <td class="paramtype">T *&#160;</td>
          <td class="paramname"><em>ptr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>d</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>frees memory on the GPU device </p>
<dl class="tparams"><dt>Template Parameters</dt><dd>
  <table class="tparams">
    <tr><td class="paramname">T</td><td>pointer type </td></tr>
  </table>
  </dd>
</dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">ptr</td><td>device pointer to memory to free </td></tr>
    <tr><td class="paramname">d</td><td>device context identifier</td></tr>
  </table>
  </dd>
</dl>
<p>This methods call <code>cudaFree</code> to free the memory space pointed to by <code>ptr</code> using the given device context. </p>

</div>
</div>
<a id="file_ae174a3a49b91ef21554dac16806f0d72"></a>
<h2 class="memtitle"><span class="permalink"><a href="#file_ae174a3a49b91ef21554dac16806f0d72">&#9670;&nbsp;</a></span>cuda_free() <span class="overload">[2/2]</span></h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T &gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">void tf::cuda_free </td>
          <td>(</td>
          <td class="paramtype">T *&#160;</td>
          <td class="paramname"><em>ptr</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>frees memory on the GPU device </p>
<dl class="tparams"><dt>Template Parameters</dt><dd>
  <table class="tparams">
    <tr><td class="paramname">T</td><td>pointer type </td></tr>
  </table>
  </dd>
</dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">ptr</td><td>device pointer to memory to free</td></tr>
  </table>
  </dd>
</dl>
<p>This methods call <code>cudaFree</code> to free the memory space pointed to by <code>ptr</code> using the current device context of the caller. </p>

</div>
</div>
<a id="file_a6f04fd3168c45eeb2dffb223e5c81e45"></a>
<h2 class="memtitle"><span class="permalink"><a href="#file_a6f04fd3168c45eeb2dffb223e5c81e45">&#9670;&nbsp;</a></span>cuda_malloc_device() <span class="overload">[1/2]</span></h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T &gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">T* tf::cuda_malloc_device </td>
          <td>(</td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>N</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>d</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>allocates memory on the given device for holding <code>N</code> elements of type <code>T</code> </p>
<p>The function calls <code>cudaMalloc</code> to allocate <code>N*sizeof(T)</code> bytes of memory on the given device <code>d</code> and returns a pointer to the starting address of the device memory. </p>

</div>
</div>
<a id="file_ab9b68b8f4336f13b190d573969cb1cf7"></a>
<h2 class="memtitle"><span class="permalink"><a href="#file_ab9b68b8f4336f13b190d573969cb1cf7">&#9670;&nbsp;</a></span>cuda_malloc_device() <span class="overload">[2/2]</span></h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T &gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">T* tf::cuda_malloc_device </td>
          <td>(</td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>N</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>allocates memory on the current device associated with the caller </p>
<p>The function calls cuda_malloc_device from the current device associated with the caller. </p>

</div>
</div>
<a id="file_a8eed05685b030fc44703213a4ef86f11"></a>
<h2 class="memtitle"><span class="permalink"><a href="#file_a8eed05685b030fc44703213a4ef86f11">&#9670;&nbsp;</a></span>cuda_malloc_shared()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T &gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">T* tf::cuda_malloc_shared </td>
          <td>(</td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>N</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>allocates shared memory for holding <code>N</code> elements of type <code>T</code> </p>
<p>The function calls <code>cudaMallocManaged</code> to allocate <code>N*sizeof(T)</code> bytes of memory and returns a pointer to the starting address of the shared memory. </p>

</div>
</div>
<a id="file_aa4266474b921f8ed7d9ec8071fded2a4"></a>
<h2 class="memtitle"><span class="permalink"><a href="#file_aa4266474b921f8ed7d9ec8071fded2a4">&#9670;&nbsp;</a></span>cuda_memcpy_async()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void tf::cuda_memcpy_async </td>
          <td>(</td>
          <td class="paramtype">cudaStream_t&#160;</td>
          <td class="paramname"><em>stream</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>dst</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const void *&#160;</td>
          <td class="paramname"><em>src</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>count</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>copies data between host and device asynchronously through a stream </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">stream</td><td>stream identifier </td></tr>
    <tr><td class="paramname">dst</td><td>destination memory address </td></tr>
    <tr><td class="paramname">src</td><td>source memory address </td></tr>
    <tr><td class="paramname">count</td><td>size in bytes to copy</td></tr>
  </table>
  </dd>
</dl>
<p>The method calls <code>cudaMemcpyAsync</code> with the given <code>stream</code> using <code>cudaMemcpyDefault</code> to infer the memory space of the source and the destination pointers. The memory areas may not overlap. </p>

</div>
</div>
<a id="file_a6615554d2954e895755411ee444d9760"></a>
<h2 class="memtitle"><span class="permalink"><a href="#file_a6615554d2954e895755411ee444d9760">&#9670;&nbsp;</a></span>cuda_memset_async()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void tf::cuda_memset_async </td>
          <td>(</td>
          <td class="paramtype">cudaStream_t&#160;</td>
          <td class="paramname"><em>stream</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>devPtr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>value</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>count</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>initializes or sets GPU memory to the given value byte by byte </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">stream</td><td>stream identifier </td></tr>
    <tr><td class="paramname">devPtr</td><td>pointer to GPU mempry </td></tr>
    <tr><td class="paramname">value</td><td>value to set for each byte of the specified memory </td></tr>
    <tr><td class="paramname">count</td><td>size in bytes to set</td></tr>
  </table>
  </dd>
</dl>
<p>The method calls <code>cudaMemsetAsync</code> with the given <code>stream</code> to fill the first <code>count</code> bytes of the memory area pointed to by <code>devPtr</code> with the constant byte value <code>value</code>. </p>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_88dad41ea55ca2177e141d32a93e931c.html">taskflow</a></li><li class="navelem"><a class="el" href="dir_638d51f8e6f20ea8c720cc8c006296ba.html">cuda</a></li><li class="navelem"><a class="el" href="cuda__memory_8hpp.html">cuda_memory.hpp</a></li>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.14 </li>
  </ul>
</div>
</body>
</html>
